/* 最大流拆点
* 1.解题思路 
    dp解决第一问: g[i]表示前i个数以a[i]结尾的最长上升子序列的个数
    对于 j<i,a[j]≤a[i], g[i]==g[j]+1, 即i可以通过j这个点转移过来
    将j向i建边，且容量为 1
    假设LIS为s，建立源点S，S向所有 g[i]=1 的i连边，且容量为1，
                建立汇点T，所有 g[i]=s的 i 向 T 连边，且容量为 1
    
    另外由于一个点可能会用到多次，但实际上只能用一次，即对点有限制，故需要拆点-拆分为入点和出点



*/

#define DEBUG
#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")

#include <iostream>
#include <cstring>
using namespace std;
const int N = 1010, M = 251010, INF = 0x3f3f3f3f;

int n, S, T;
int h[N], e[M], c[M], ne[M], idx;
int q[N], d[N], cur[N];
int w[N], g[N];

void AddEdge(int a, int b, int w)
{
    e[idx] = b, c[idx] = w, ne[idx] = h[a], h[a] = idx++;
    e[idx] = a, c[idx] = 0, ne[idx] = h[b], h[b] = idx++;
}

bool bfs()
{
    memset(d, -1, sizeof d);
    int hh = 0, tt = -1;
    q[++tt] = S, d[S] = 0, cur[S] = h[S];
    while(hh <= tt)
    {
        int u = q[hh++];
        for(int i = h[u]; ~i; i = ne[i])
        {
            int v = e[i];
            if(d[v] == -1 && c[i])
            {
                d[v] = d[u]+1;
                cur[v] = h[v];
                if(v == T) return true;
                q[++tt] = v;
            }
        }
    }
    return false;
}

int find(int u, int limit)
{
    if(u == T) return limit;
    int flow = 0;
    for(int i = cur[u]; ~i && flow < limit; cur[u] = i, i = ne[i])
    {
        int v = e[i];
        if(d[v] == d[u] + 1 && c[i])
        {
            int t = find(v, min(c[i], limit-flow));
            if(!t) d[v] = -1;
            c[i] -= t, c[i^1] += t, flow += t;
        }
    }
    return flow;
}

int Dinic()
{
    int r = 0, flow;
    while(bfs())
        while(flow = find(S, INF)) r += flow;
    return r;
}

signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
    #else
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #endif

    cin >> n;
    S = 0, T = 2*n+1;
    memset(h, -1, sizeof h);

    for(int i = 1; i <= n; i++) cin >> w[i];
    int s = 0;
    for(int i = 1; i <= n; i++)
    {
        AddEdge(i, i+n, 1); //每个点只能用一次
        g[i] = 1;
        for(int j = 1; j < i; j++)
            if(w[j] <= w[i])
                g[i] = max(g[i], g[j] + 1); //最长不递减子序列

        for(int j = 1; j < i; j++)
            if(w[j] <= w[i] && g[i] == g[j] + 1)
                AddEdge(j+n, i, 1);
        s = max(s, g[i]);        
        if(g[i] == 1) AddEdge(S, i, 1); //从源点建边
    }

    for(int i = 1; i <= n; i++)
        if(g[i] == s) AddEdge(i+n, T, 1); //向汇点建边

    printf("%d\n", s);
    if(s == 1) printf("%d\n%d\n", n, n); //每个节点都是最长不下降子序列
    else{
        int res = Dinic();
        printf("%d\n", res);
        for(int i = 0; i < idx; i += 2)
        {
            int a = e[i^1], b = e[i];
            if(a == S && b == 1) c[i] = INF; //虚拟源点到首节点
            else if(a == 1 && b == n+1) c[i] = INF; //首节点与自身
            else if(a == n && b == n+n) c[i] = INF; //末节点与自身
            else if(a == n+n && b == T) c[i] = INF; //末节点的出边到虚拟汇点
        }
        printf("%d\n", res + Dinic());
    }
    return 0;
}